package com.tyning.designpattern.subject.impl;

import com.another.designpattern.subject.Subject;
import com.another.designpattern.subject.Observer;

import java.util.ArrayList;
import java.util.List;

/**
 * 具体主题
 */
public class ConcreteSubject implements Subject {

    List<Observer> observerList = new ArrayList<Observer>();
    public void addObserver(Observer observer) {
        observerList.add(observer);
    }

    public void removeObserver(Observer observer) {
        observerList.remove(observer);
    }

    public void Notify() {
        for (Observer observer : observerList){
            observer.run();
        }
    }
}

